package com.study.day1;

/**
 * 模版
 */
class Solution58 {

    public static String reverseLeftWords(String s, int n) {
        String res = "";
        int len = n + s.length();
        for(int i = n; i < len; i++) {
            int j = i % s.length();
            res += s.charAt(j);
        }
        return res;
    }

    public static String reverseLeftWords1(String s, int n) {
        return s.substring(n) + s.substring(0, n);
    }

    public static String reverseLeftWords2(String s, int n) {
        StringBuilder res = new StringBuilder();
        for (int i = n; i < n + s.length(); i++) {
            res.append(s.charAt(i % s.length()));
        }
        return res.toString();
    }


    public static void main(String[] args) {
        // ======= Test Case =======
        String s = reverseLeftWords("abcdefg", 2);
        String s1 = reverseLeftWords1("abcdefg", 2);
        String s2 = reverseLeftWords1("abcdefg", 2);
        System.out.println(s);
        System.out.println(s1);
        System.out.println(s2);
        // Build next reference

    }
}

